<?php
namespace AuctionCore\Spm;
use AuctionCore\Spm\AccountManage;
/**
 * 用户登录管理
 */
use AuctionCore\Account\Back\Employee;

/**
 * 车源列表
 * @author       shijiabing
 */
class IndexShow extends \AuctionSpm\Controller\BaseController {
     //初始化
    public function __construct() {           
        parent::__construct();
    }
    public function get($ev_page_num, $page) {
        
    }
    public function count() {
        
    }
    /**
     * 查询数量
     * @return [type] [description]
     */
    public function counts($params){
        $user_m = new AccountManage();
        $map1 = $user_m->getFourMap();

        $map['suggest_max_price'] = array('neq',' ');
        $map['suggest_min_price'] = array('neq',' ');
        $map = array_merge($map,$map1);
        $where = array_merge($map,$params);
        //$map1 = $this->getFourId(array(1,2,3,25));//查询属于4s店的车源---数组-多个店
        // $map1 = $this->getFourId(42);//查询属于4s店的车源---单个点
        $result = M('cars')->alias('c')
                           ->join('LEFT JOIN `__ORDER__` o ON c.car_id=o.car_id')
                           ->join(C('DB_PREFIX')."car_owner as co ON co.owner_id=c.owner_id")
                           ->where($where)
                           ->count('distinct c.car_id');
        // echo M()->getLastSql();
        return $result;
    }
    /**
     * 获取车源所属的4s店id
     * @param maxed $params 
     * @return [type] [description]
     */
    public function getFourId($params){
        $float = is_array($params);
        if($float){
            $map['co.comefrom'] = array('in',$params);
        } else{
            $map['co.comefrom'] = array('eq',$params);
        }
        return $map;
    }
    public function getInfo(){
        //待上拍
        $map1['o.status'] = array('in', array(1,2));
        $map1['c.car_status'] = array('in',array('4','7'));
        $map1['_logic'] = 'or';
        $map11['_complex'] = $map1;
        $info1 = $this->counts($map11);
        //拍卖中
        $map2['o.status'] = array('in',array(3,301,4));
        $info2 = $this->counts($map2);
        // 待确认
        $map3['o.status'] = array('eq',5);
        $info3 = $this->counts($map3);
        // 交易中
        $map4['o.status'] = array('in', array(7,8,9,10,11));
        $info4 = $this->counts($map4);
        // 参拍量
        $map5['co.business_status'] = array('notin', array(1,2,3));
        $info5 = $this->counts($map5);
        // 交易成功
        $map6['c.car_status'] = array('eq', 9);
        $map6['o.status'] = array('eq',13);
        $info6 = $this->counts($map6);
        // 交易失败
        $map7['c.car_status'] = array('eq', 8);
        $info7 = $this->counts($map7);
        //全部车辆
        $info8 = $info1 + $info2;
        //全部订单
        $info9 = $info3 + $info4 + $info6 + $info7;
        $info = array(
                'info1' => $info1,
                'info2' => $info2,
                'info3' => $info3,
                'info4' => $info4,
                'info5' => $info5,
                'info6' => $info6,
                'info7' => $info7,
                'info8' => $info8,
                'info9' => $info9
            );
        // echo M()->getLastSql();
        return $info;
    }

}